package org.example.library_management_system.mapper;


import org.apache.ibatis.annotations.*;
import org.example.library_management_system.Model.BookInfo;
import org.example.library_management_system.Model.PageRequest;

import java.util.List;

@Mapper
public interface IBookInfoMapper {

    @Insert("insert into book_info (book_name,author,count,price,public,status) values (#{bookName},#{author},#{count},#{price},#{publish},#{status});")
    Integer insertBookInfo(BookInfo bookInfo);


    @Result(column = "public", property = "publish")
    @Select("select id,book_name,author,count,price,`public`,`status`,create_time,update_time from book_info where status!=0 limit #{offset} , #{pageSize} ")
    List<BookInfo> selectPageBooks(Integer offset,Integer pageSize);

    @Select("select count(id) from book_info where status!=0")
    Integer selectBooksNums();


    BookInfo selectBookInfoByIdOrName(BookInfo bookInfo);
    @Result(column = "public", property = "publish")
    @Select("select id,book_name,author,count,price,`public`,`status`,create_time,update_time from book_info where id = #{id} ")
    BookInfo selectBookInfoById(Integer id);


    public Integer updateBookInfoById(BookInfo bookInfo);

    @Update("update book_info set status = #{status} where id = #{id}")
    public Integer deleteBookInfoById(BookInfo bookInfo);


    public Integer deleteBookInfoByIds(List<Integer> ids);
}
